#include <bits/stdc++.h>

using namespace std;
const int N=1e5+5;

int a[N],ans=0;
bool c[N];

void dfs(int x,int n){
    if(x>=n){
        int l0=0,l1=0,res=0;
        for(int i=1;i<=n;i++){
            if(c[i]){
                if(l1&&a[l1]==a[i])
                    res+=a[i];
                l1=i;
            }
            else{
                if(l0&&a[l0]==a[i])
                    res+=a[i];
                l0=i;
            }
        }
        ans=max(ans,res);
        return;
    }
    c[x]=0;
    dfs(x+1,n);
    c[x]=1;
    dfs(x+1,n);
}

void solve(){
    ans=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];

    dfs(1,n);
    cout<<ans<<'\n';
}

signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int _;
    cin>>_;
    while(_--)solve();
    return 0;
}
